// TypeScript
import { v2 as webdav } from "webdav-server";
// JavaScript
const webdav = require("webdav-server").v2;

const server = new webdav.WebDAVServer({
  port: 1900,
});

server.afterRequest((arg, next) => {
  // 输出请求的方法、URI、返回的状态码及其消息
  console.log(
    ">>",
    arg.request.method,
    arg.requested.uri,
    ">",
    arg.response.statusCode,
    arg.response.statusMessage
  );
  // 如果存在，输出响应体
  console.log(arg.responseBody);
  next();
});

server.start(() => console.log("READY"));
